#pragma once
#include <iostream>
#include <pthread.h>

class Lock
{
public:
    Lock()
    {
        pthread_mutex_init(&_mtx, nullptr);
    }

    // 加锁
    void lock()
    {
        pthread_mutex_lock(&_mtx);
    }

    // 解锁
    void unlock()
    {
        pthread_mutex_unlock(&_mtx);
    }

    // 析构 -- 销毁锁
    ~Lock()
    {
        pthread_mutex_destroy(&_mtx);
    }

private:
    pthread_mutex_t _mtx;
};